{template header}

<style>
    .event-show-content{}
    .event-show-content img{max-width: 100%;}
</style>

<div class="container">



<div class="row">


<div class="col-md-8">









    <div class="panel panel-default">
        <div class="panel-body">


            <div class="page-header">
                <h1>{$strEvent[title]}
                    <small>

                </small></h1>

            </div>





            <div class="row">
                <div class="col-md-6"><img style="width:100%;" title="点击看大图" src="{if $strEvent[photo]}{php echo tsXimg($strEvent[photo],'event',500,'',$strEvent[path])}{else}{SITE_URL}app/event/skins/default/event.jpg{/if}" /></div>
                <div class="col-md-6">



                    <div class="c9 f12"  style="line-height: 20px">
                        开始时间：{php echo date('Y-m-d H:i',$strEvent[starttime])}<br/>
                        结束时间： {php echo date('Y-m-d H:i',$strEvent[endtime])}<br/>
                        报名期限： {php echo date('Y-m-d H:i',$strEvent[limittime])}<br/>
                        报名资格：{if $strEvent[duty]>0}服务时长不少于{php echo $strEvent[duty]}{else}不限{/if}<br/>
                        费用：{$strEvent['price']}<br/>

                        地点： {$strEvent[address]}<br/>
                        发起人： <a href="{tsUrl('user','duty',array('id'=>$strEvent[user][userid]))}">{$strEvent[user][username]}</a> <br>
                        {if $arrOrganizer}
                        组织者：
                        {loop $arrOrganizer $key $item}
                        <a href="#">{$item[username]}</a> &nbsp;
                        {/loop}
                        <br>
                        {/if}
                        类型： <a href="{tsUrl('event','type',array('id'=>$strEvent['type']['typeid']))}">{$strEvent[type][typename]}</a><br>
                        名额：{if $strEvent['quota']==0}不限{else}{$strEvent['quota']}{/if}<br/>
                        报名人数：{$strEvent[count_userwish]}<br/>
                        实到人数：{$strEvent[count_userdo]}<br/>
                        点赞：{$strEvent[count_recommend]}
                    </div>



                    <div class="tar">
                        {if $GLOBALS[TS_USER][userid]!=''&&$strEvent[userid]!=$GLOBALS[TS_USER][userid]}
                        <a class="pull-right" style="margin-left: 5px" href="javascript:void('0');" onclick="recommend({$strEvent[eventid]})">{if $isRecommend==0}<i class="fa fa-heart-o"></i> 赞{else}<i class="fa fa-heart"></i> 取消{/if}</a>
                        {/if}
                        {if $strEvent[limittime]<=time()}
                        报名已截止
                        {else}
                            {if $isEventUser<>'0'}
                                <a class="btn btn-default" href="javascript:void('0');" onclick="cancelEvent('{$strEvent[eventid]}');"> 我不去了</a>
                            {else}
                               {if $strEvent['quota']>0&&$strEvent['quota']<=$strEvent['count_userwish']}
                                    已报满
                                {else}
                                 <a class="btn btn-success" data-toggle="modal" data-target="#do_event_form">我要参加</a>
                                 {/if}
                            {/if}
                        {/if}
                    </div>




                </div>
            </div>












</div>

</div>









    <div class="panel panel-default">
        <div class="panel-heading">活动介绍</div>
        <div class="panel-body">
            <div class="event-content">
                <div class="event-view">

                    <p>{$strEvent[content]}</p>
                </div>
            </div>

<div style="text-align:right;">
{if $GLOBALS[TS_USER][userid] == $strEvent[userid] || $GLOBALS[TS_USER][isadmin]=='1'}
<a href="{tsUrl('event','edit',array('ts'=>'base','eventid'=>$strEvent['eventid']))}">修改</a>&nbsp;&nbsp;<a href="{SITE_URL}index.php?app=event&ac=delete&ts=base&eventid={$strEvent[eventid]}&token={$_SESSION['token']}"  onClick="return confirm('确定删除吗?')">删除</a>
{/if}
</div>

</div>
</div>




    <div class="panel panel-default">
        <div class="panel-heading">{if $GLOBALS[TS_USER][userid] == $strEvent[userid] || $GLOBALS[TS_USER][isadmin]=='1'}<a href="{tsUrl('event','edit',array('ts'=>'join','eventid'=>$eventid))}">{/if}报名的人{if $GLOBALS[TS_USER][userid] == $strEvent[userid] || $GLOBALS[TS_USER][isadmin]=='1'}</a>{/if} <small>({$strEvent[count_userwish]}人，名字为绿色表示实际出席)</small></div>
        <div class="panel-body">



            <div class="facelist">
                <ul>
                {loop $arrDoUser $key $item}
                <li>
                    <a href="{tsUrl('user','duty',array('id'=>$item[userid]))}">
                        <img class="img-circle" src="{$item['user'][face]}" alt="{$item['user']['username']}"  width="48" height="48" />
                    </a>
                    <div class="username">
                        {if $item['status']==0}
                        <a {if $GLOBALS[TS_USER][userid] == $strEvent[userid] || $GLOBALS[TS_USER][isadmin]=='1'}href="javascript:void('0');" onclick="attendEvent({$strEvent[eventid]},{$item['userid']})"{/if} style="color:orange">{$item['user']['username']}</a>
                        {else}
                        <a {if $GLOBALS[TS_USER][userid] == $strEvent[userid] || $GLOBALS[TS_USER][isadmin]=='1'}href="javascript:void('0');" onclick="absentEvent({$strEvent[eventid]},{$item['userid']})"{/if} style="color: green">{$item['user']['username']}</a>
                        {/if}
                    </div>
                </li>
                {/loop}
                </ul>
            </div>



</div>
</div>


    <div class="panel panel-default">
        <div class="panel-heading">你的回应</div>
        <div class="panel-body">

            <div class="comment">

<ul>

{loop $arrComment $key $item}
<li class="clearfix">
    <div class="user-face">
        <a href="{tsUrl('user','duty',array('id'=>$item[user][userid]))}"><img title="{$item[user][username]}" alt="{$item[user][username]}" src="{$item[user][face]}" class="pil img-circle" width="48" height="48" /></a>
    </div>
    <div class="reply-doc">
            <h4>{php echo date('Y-m-d H:i:s',$item[addtime])}
                <a href="{tsUrl('user','topic',array('id'=>$item[userid]))}">{$item[user][username]}</a>
            </h4>
        <p>{$item[content]}</p>
	
	   {if $GLOBALS[TS_USER][userid] == $strEvent[userid]|| $GLOBALS[TS_USER][isadmin]=='1'}
        <div class="group_banned">
            <span><a class="j a_confirm_link" onclick="return confirm('确定删除?')" href="{SITE_URL}index.php?app=event&ac=delete&ts=comment&eventid={$strEvent['eventid']}&commentid={$item['commentid']}">删除</a>
            </span>
        </div>
	{/if}
	
    </div>
</li>
{/loop}
</ul>

            </div>

<div class="page">{$pageUrl}</div>

{if $GLOBALS[TS_USER][userid] == ''}
<div style="font-size:14px;padding:40px 0;text-align:center;">请登录后回应本活动^_^</div>
{else}
<div>
<form method="POST" action="{tsUrl('event','comment')}"  onSubmit="return submitonce(this)" id="formMini" {if $strEvent[limittime]>time()&&!$isEventUser}onclick="noreply()"{/if}>
    <div class="wangeditor_toolbar" id="tseditor"></div>
    <div class="wangeditor_text" id="tseditor2"></div>
    <div style="display: none" ><textarea id="content" name="content" ></textarea></div>
<input type="hidden" name="eventid" value="{$strEvent[eventid]}" />
<input class="btn btn-success" type="submit" value="发表回复">
</form>
</div>
{/if}
</div>
</div>
</div>
<div class="col-md-4">
    <div class="panel panel-default">
        <div class="panel-body">
<a href="{tsUrl('event','type',array(id=>$strEvent[type][typeid]))}">更多{$strEvent[type][typename]}活动</a>
</div>
</div>

{if $strEvent['coordinate']}

    <div id="container" style="width:100%;height:300px;"></div>

    <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=dbf1281241fe7a7a9c04b486e1a31651"></script>
    <script type="text/javascript">
        //初始化地图对象，加载地图
        var map = new AMap.Map("container", {
            resizeEnable: true,
            center: [{$strEvent['coordinate']}],//地图中心点
            zoom: 13 //地图显示的缩放级别
        });
        //添加点标记，并使用自己的icon
        new AMap.Marker({
            map: map,
            position: [{$strEvent['coordinate']}],
            icon: new AMap.Icon({
                size: new AMap.Size(40, 50),  //图标大小
                image: "http://webapi.amap.com/theme/v1.3/images/newpc/way_btn2.png",
                imageOffset: new AMap.Pixel(0, -60)
            })
        });
    </script>

    {/if}




    <!--广告位-->
    {php doAction('gobad','300')}


</div>


</div>
</div>


<div id="do_event_form" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true" >
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h5 class="modal-title">活动报名</h5>
            </div>
            <div class="modal-body" >
<form  id="join_form" class="form-horizontal" method="post" action="{SITE_URL}index.php?app=event&ac=do&ts=join">

  <div class="form-group">
    <label class="col-sm-2 control-label">姓名</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="username" name="username" value="{$_SESSION['tsuser']['username']}">
    </div>
  </div>
  
   <div class="form-group">
    <label class="col-sm-2 control-label">手机</label>
    <div class="col-sm-10">
      <input type="text" class="form-control" id="phone" name="phone" value="{$_SESSION['tsuser']['phone']}">
    </div>
  </div>


    <div class="form-group">
        <label class="col-sm-2 control-label">所在团队</label>

        <div class="col-sm-10">
        <select id="groupid" name="groupid" class="form-control">
            <option></option>
            {loop $arrGroup $key $item}
            <option value="{$item['groupid']}"  {if $item['groupid']==$_SESSION['tsuser']['groupid']}selected{/if}>{$item['groupname']}</option>
            {/loop}
        </select>
            </div>
    </div>


    <div class="form-group">
        <label class="col-sm-2 control-label">所属机构</label>
        <div class="col-sm-10">
        <select id='orgid' name="orgid" class="form-control">
            <option value=""></option>
            {loop $arrOrg $key $item}
            <option value="{$item['orgid']}" {if $_SESSION['tsuser']['orgid']==$item['orgid']}selected{/if}>{$item['orgname']}</option>
            {/loop}
        </select>
            </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">附言</label>
        <div class="col-md-10">
            <textarea class="form-control" id="memo" name="memo" rows="6"  placeholder='说点儿什么呗'  ></textarea>
        </div>
    </div>

  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
	
	<input type="hidden" name="eventid" value="{$strEvent['eventid']}" />
	
      <button type="submit" class="btn btn-success">点击提交</button>
    </div>
  </div>
</form>

</div>
</div>
</div>
</div>
<script>
    $(function(e){
        $('#join_form').on('submit', function(e) {
            var eventid  = $('#eventid').val();
            var orgid  = $('#orgid').val();
            var groupid  = $('#groupid').val();
            var username  = $('#username').val();
            var phone = $('#phone').val();


            if(username==''){
                bootbox.alert('姓名必填');
                return false;
            }

            if(phone==''){
                bootbox.alert('手机必填');
                return false;
            }

            $.ajax({
                type: "POST",
                dataType: 'json',
                url: "{SITE_URL}index.php?app=event&ac=do&ts=join",
                data: {eventid:eventid,orgid:orgid,groupid:groupid,username:username,phone:phone},
                success: function(data) {
                    if(data.status == '1'){
                        $('#do_event_form').modal('hide');
                        location.reload();
                    }
                }
            });

       });

    });

    $(function(){
        $('#formMini').on('submit', function(e) {

            var content  = $('#content').val();

            //var text = Trim(content);
           // if(text == ''){
               // bootbox.alert('内容不能为空');
                //return false;
       //     }

        });

    });

    //确认出席
    function attendEvent(eventid,userid){


        if (confirm('确定此人出席了吗？')) {

            $.ajax({
                type: "POST",
                url: siteUrl+"index.php?app=event&ac=do&ts=attend",
                data: "eventid="+eventid+"&memberid="+userid,
                beforeSend:function(){
                },
                success:function(result){
                    if(result == '1'){
                        window.location.reload();
                    }
                }
            });

        }
    }

    //确认缺席
    function absentEvent(eventid,userid){


        if (confirm('确定此人缺席了吗？')) {

            $.ajax({
                type: "POST",
                url: siteUrl+"index.php?app=event&ac=do&ts=absent",
                data: "eventid="+eventid+"&memberid="+userid,
                beforeSend:function(){
                },
                success:function(result){
                    if(result == '1'){
                        window.location.reload();
                    }
                }
            });

        }
    }

   function noreply(){
       bootbox.alert('报名后才可以回复，请先点击上方“我要参加”按钮报名。如想咨询活动问题，请私信发布者。');
   }

</script>
{php doAction('tseditor','mini')}
{template footer}